package com.xiyan.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiyan.blog.entity.Blog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper extends BaseMapper<Blog> {

    @Select("select b.* from " +
            "(select bt.* from blog_tag bt where bt.user_id = {userId} and bt.tag_id = {tagId}) as btt , " +
            "blog b " +
            "where b.id = btt.blog_id")
    List<Blog> findByTagId(String userId, String tagId);
}
